package camtburist.app02.service.impl;

import camtburist.app02.bean.Article;
import camtburist.app02.dao.ArticleMapper;
import camtburist.app02.service.IArticleServic;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class IArticleServicImpl implements IArticleServic {
    @Resource
    private ArticleMapper articleMapper;

    @Override
    public List<Article> findAll() {
        return articleMapper.selectAll();
    }

    @Override
    public void saveOrupdate(Article article) {
        if (article.getId()!=null){
             articleMapper.update(article);
        }else {
            articleMapper.insert(article);
        }

    }

    @Override
    public void deleteById(long id) {
     articleMapper.deleteById(id);
    }
}
